﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:s="clr-namespace:DiagramDesigner">
  <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="MoveThumb.xaml"/>
    <ResourceDictionary Source="ResizeDecorator.xaml"/>
    <ResourceDictionary Source="RotateDecorator.xaml"/>
  </ResourceDictionary.MergedDictionaries>

  <!-- ContentControl style to move, resize and rotate items -->
  <Style x:Key="DesignerItemStyle" TargetType="ContentControl">
    <Setter Property="MinHeight" Value="50"/>
    <Setter Property="MinWidth" Value="50"/>    
    <Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>
    <Setter Property="SnapsToDevicePixels" Value="true"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="ContentControl">
          <Grid DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}">
            <Control Name="RotateDecorator"
                     Template="{StaticResource RotateDecoratorTemplate}"
                     Visibility="Collapsed"/>
            <s:MoveThumb Template="{StaticResource MoveThumbTemplate}"
                         Cursor="SizeAll"/>
            <Control x:Name="ResizeDecorator"
                     Template="{StaticResource ResizeDecoratorTemplate}"
                     Visibility="Collapsed"/>
            <ContentPresenter Content="{TemplateBinding ContentControl.Content}"/>
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="Selector.IsSelected" Value="True">
              <Setter TargetName="ResizeDecorator" Property="Visibility" Value="Visible"/>
              <Setter TargetName="RotateDecorator" Property="Visibility" Value="Visible"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

</ResourceDictionary>
